package com.example.day07.homework;

import java.util.Scanner;

public class FindCommonMax {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String s1=scanner.nextLine();
        String s2=scanner.nextLine();
        String result="";
        result=findCommon(s1,s2);
        System.out.println(s1+"和"+s2+"的最长子序列是 :"+result);
    }

    private static String findCommon(String s1, String s2) {

        String maxlen= s1.length()>s2.length()?s1:s2;
        String minlen= s1.length()>s2.length()?s2:s1;
        String str="";
        OUT:
        for(int i=0;i<minlen.length();i++){
            for( int j=0;j<=i;j++){
                String  substr=s2.substring(j,minlen.length()-i+j);
                if(maxlen.contains(substr)){     //判断最小的字符串整串是否在长的字符串当中
                    if(substr.length()>str.length()){
                        str=substr;
                        break OUT;
                    }
                }
            }
        }
            return  str;

    }
}
